

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/IKKIS_LOGO.png">
  <link rel="icon" href="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/IKKIS_LOGO.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Ikki">
  <meta name="keywords" content="">
  
    <meta name="description" content="1.软件包管理    RPM是RedHat Package Manager（RedHat软件包管理工具）类似Windows里面的”添加&#x2F;删除程序”  1.1 软件包的分类 源码包(需要经过编译，把人所编写的源代码编译成机器语言才能运行) 优点   开源免费   可以自由配置功能   编译安装更适合自己系统，更稳定   卸载方便   缺点   安装过程比较复杂   编译过程比较长   安装过程一旦报">
<meta property="og:type" content="article">
<meta property="og:title" content="06.软件包管理">
<meta property="og:url" content="http://81.68.132.127/2022/10/24/dev_ops/linux/%E8%BD%AF%E4%BB%B6%E5%8C%85%E7%AE%A1%E7%90%86/index.html">
<meta property="og:site_name" content="IKKI">
<meta property="og:description" content="1.软件包管理    RPM是RedHat Package Manager（RedHat软件包管理工具）类似Windows里面的”添加&#x2F;删除程序”  1.1 软件包的分类 源码包(需要经过编译，把人所编写的源代码编译成机器语言才能运行) 优点   开源免费   可以自由配置功能   编译安装更适合自己系统，更稳定   卸载方便   缺点   安装过程比较复杂   编译过程比较长   安装过程一旦报">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/beijing/iTab-e7j33o.jpeg">
<meta property="article:published_time" content="2022-10-23T22:45:06.000Z">
<meta property="article:modified_time" content="2022-10-24T09:52:59.604Z">
<meta property="article:author" content="Ikki">
<meta property="article:tag" content="运维">
<meta property="article:tag" content="linux">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/beijing/iTab-e7j33o.jpeg">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>06.软件包管理 - IKKI</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  



  
<link rel="stylesheet" href="/fluid/css/fluid-extention.css">
<link rel="stylesheet" href="/fluid/css/nihao.css">



  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"81.68.132.127","root":"/","version":"1.9.3","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"left","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":3},"lazyload":{"enable":true,"loading_img":"https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 5.4.2"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 100vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>Ikki-BUG制造者</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('http://image.ikki0603.cn') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="06.软件包管理"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2022-10-24 06:45" pubdate>
          2022年10月24日 早上
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          3.5k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          30 分钟
        
      </span>
    

    
    
      
        <span id="busuanzi_container_page_pv" style="display: none">
          <i class="iconfont icon-eye" aria-hidden="true"></i>
          <span id="busuanzi_value_page_pv"></span> 次
        </span>
        
      
    
  </div>


        
      </div>

      
        <div class="scroll-down-bar">
          <i class="iconfont icon-arrowdown"></i>
        </div>
      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="padding-left: 2rem; margin-right: -1rem">
    <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">06.软件包管理</h1>
            
              <p class="note note-info">
                
                  
                    本文最后更新于：2022年10月24日 下午
                  
                
              </p>
            
            
              <div class="markdown-body">
                
                <h2 id="1-软件包管理"><a href="#1-软件包管理" class="headerlink" title="1.软件包管理 "></a>1.软件包管理 </h2><ul>
<li>  RPM是RedHat Package Manager（RedHat软件包管理工具）类似Windows里面的”添加/删除程序”</li>
</ul>
<h3 id="1-1-软件包的分类"><a href="#1-1-软件包的分类" class="headerlink" title="1.1 软件包的分类"></a>1.1 软件包的分类</h3><ul>
<li>源码包(需要经过编译，把人所编写的源代码编译成机器语言才能运行)<ul>
<li>优点<ul>
<li>  开源免费</li>
<li>  可以自由配置功能</li>
<li>  编译安装更适合自己系统，更稳定</li>
<li>  卸载方便</li>
</ul>
</li>
<li>缺点<ul>
<li>  安装过程比较复杂</li>
<li>  编译过程比较长</li>
<li>  安装过程一旦报错，非常难以排查</li>
</ul>
</li>
</ul>
</li>
<li>二进制包(把源代码包经过编译生成0/1二进制，PRM包、系统默认的安装包)<ul>
<li>优点<ul>
<li>  包管理系统比较简单，只要通过简单的命令就可以实现包的安装、升级、查询和卸载</li>
<li>  安装速度比源码包快很多</li>
</ul>
</li>
<li>缺点<ul>
<li>  经过编译则不能看到源代码</li>
<li>  功能选择不灵活</li>
<li>  依赖性比较麻烦</li>
</ul>
</li>
</ul>
</li>
<li>脚本安装包(就是把复杂的安装过程写成了脚本，可以一键安装，本质上安装的还是源代码包和二进制包)<ul>
<li>  优点是安装简单</li>
<li>  缺点是失去了自定义性</li>
</ul>
</li>
</ul>
<h2 id="2-YUM在线管理"><a href="#2-YUM在线管理" class="headerlink" title="2. YUM在线管理 "></a>2. YUM在线管理 </h2><ul>
<li>  yum = Yellow dog Updater, Modified主要功能是更方便的添加/删除/更新RPM包.它能自动解决包的倚赖性问题.</li>
<li>  这是rpm包的在线管理命令</li>
<li>  将所有的软件名放到官方服务器上，当进行YUM在线安装时，可以自动解决依赖性问题</li>
<li>/etc/yum.repos.d/<ul>
<li>  CentOS-Base.repo</li>
<li>  epel.repo</li>
</ul>
</li>
</ul>
<h3 id="2-1-CentOS-Base-repo"><a href="#2-1-CentOS-Base-repo" class="headerlink" title="2.1 CentOS-Base.repo"></a>2.1 CentOS-Base.repo</h3><figure class="highlight ini"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-bgg6rvlacl5vph"></i><span>ini</span><div class="collapse show" id="collapse-bgg6rvlacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs ini"><span class="hljs-section">[base]</span><br><span class="hljs-attr">name</span>=CentOS-<span class="hljs-variable">$releasever</span><br><span class="hljs-attr">enabled</span>=<span class="hljs-number">1</span><br><span class="hljs-attr">failovermethod</span>=priority<br><span class="hljs-attr">baseurl</span>=http://mirrors.cloud.aliyuncs.com/centos/<span class="hljs-variable">$releasever</span>/os/<span class="hljs-variable">$basearch</span>/<br><span class="hljs-attr">gpgcheck</span>=<span class="hljs-number">1</span><br><span class="hljs-attr">gpgkey</span>=http://mirrors.cloud.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-<span class="hljs-number">7</span><br><br></code></pre></td></tr></table></div></figure>

<table>
<thead>
<tr>
<th>字段</th>
<th>含义</th>
</tr>
</thead>
<tbody><tr>
<td>base</td>
<td>容器名称，一定要放在[]中</td>
</tr>
<tr>
<td>name</td>
<td>容器说明，可以自己随便写</td>
</tr>
<tr>
<td>mirrorlist</td>
<td>镜像站点，可以注释掉</td>
</tr>
<tr>
<td>baseurl</td>
<td>YUM源服务器的地址，默认是CentOS官方的YUM源</td>
</tr>
<tr>
<td>enable</td>
<td>此容器是否生效 不写或者写成enable=1表示生效，写成enable=0表示不生效</td>
</tr>
<tr>
<td>gpgcheck</td>
<td>如果是1就是指 RPM的数字证书生效,如果是0则表示不生效</td>
</tr>
<tr>
<td>gpgkey</td>
<td>数字证书的公钥文件保存位置，不用改</td>
</tr>
</tbody></table>
<p>使用阿里云镜像</p>
<figure class="highlight awk"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-s8urjhlacl5vph"></i><span>awk</span><div class="collapse show" id="collapse-s8urjhlacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs awk">mv <span class="hljs-regexp">/etc/yum</span>.repos.d<span class="hljs-regexp">/CentOS-Base.repo /</span>etc<span class="hljs-regexp">/yum.repos.d/</span>CentOS-Base.repo.backup<br>wget -O <span class="hljs-regexp">/etc/yum</span>.repos.d<span class="hljs-regexp">/CentOS-Base.repo http:/</span><span class="hljs-regexp">/mirrors.aliyun.com/</span>repo/Centos-<span class="hljs-number">7</span>.repo<br>yum makecache<br>yum -y update <span class="hljs-regexp">//</span>升级所有包同时也升级软件和系统内核<br><br></code></pre></td></tr></table></div></figure>

<h2 id="3-YUM命令"><a href="#3-YUM命令" class="headerlink" title="3. YUM命令 "></a>3. YUM命令 </h2><ul>
<li>  yum安装只需要写包名即可</li>
</ul>
<table>
<thead>
<tr>
<th>命令</th>
<th>含义</th>
</tr>
</thead>
<tbody><tr>
<td>yum list</td>
<td>查询所有可用软件包列表</td>
</tr>
<tr>
<td>yum search 关键字</td>
<td>搜索服务器上所有和关键字相关的包</td>
</tr>
<tr>
<td>yum -y install 包名</td>
<td>-y 自动回答yes install安装</td>
</tr>
<tr>
<td>yum -y update 包名</td>
<td>-y 自动回答yes update升级</td>
</tr>
<tr>
<td>yum -y remove 包名</td>
<td>-y 自动回答yes remove 卸载,卸载有依赖性，所以尽量不要卸载</td>
</tr>
<tr>
<td>yum grouplist</td>
<td>列出所有可用的软件组列表</td>
</tr>
<tr>
<td>yum groupinstall 软件组名</td>
<td>安装指定的组，组名可以用grouplist查询</td>
</tr>
<tr>
<td>yum groupremove 软件组名</td>
<td>卸载指定软件组</td>
</tr>
</tbody></table>
<figure class="highlight awk"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-yv7voblacl5vph"></i><span>awk</span><div class="collapse show" id="collapse-yv7voblacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs awk">yum -y install gcc  <span class="hljs-regexp">//</span>安装C语言安装包<br><br></code></pre></td></tr></table></div></figure>

<h2 id="4-常用软件安装"><a href="#4-常用软件安装" class="headerlink" title="4. 常用软件安装 "></a>4. 常用软件安装 </h2><h3 id="4-1-nginx"><a href="#4-1-nginx" class="headerlink" title="4.1 nginx"></a>4.1 nginx</h3><figure class="highlight cmake"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-etzntelacl5vph"></i><span>cmake</span><div class="collapse show" id="collapse-etzntelacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs cmake">yum <span class="hljs-keyword">install</span> nginx  -y<br><br></code></pre></td></tr></table></div></figure>
<figure class="highlight awk"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-vw1f0olacl5vph"></i><span>awk</span><div class="collapse show" id="collapse-vw1f0olacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs awk">whereis nginx <span class="hljs-regexp">//</span>查看安装位置<br><br></code></pre></td></tr></table></div></figure>

<p>启动服务</p>
<figure class="highlight awk"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-v6v06olacl5vph"></i><span>awk</span><div class="collapse show" id="collapse-v6v06olacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs awk"><span class="hljs-regexp">/bin/</span>systemctl start nginx.service<br><span class="hljs-regexp">/bin/</span>systemctl stop nginx.service<br><br></code></pre></td></tr></table></div></figure>
<figure class="highlight awk"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-l4xe79lacl5vph"></i><span>awk</span><div class="collapse show" id="collapse-l4xe79lacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs awk">curl http:<span class="hljs-regexp">//</span><span class="hljs-number">115.29</span>.<span class="hljs-number">148.6</span>/<br><br></code></pre></td></tr></table></div></figure>

<h3 id="4-2-mongodb"><a href="#4-2-mongodb" class="headerlink" title="4.2 mongodb"></a>4.2 mongodb</h3><h4 id="4-2-1-添加安装源"><a href="#4-2-1-添加安装源" class="headerlink" title="4.2.1 添加安装源"></a>4.2.1 添加安装源</h4><ul>
<li>  vim /etc/yum.repos.d/mongodb-org-3.4.repo</li>
</ul>
<p>添加以下内容：</p>
<figure class="highlight awk"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-yxwxo4lacl5vph"></i><span>awk</span><div class="collapse show" id="collapse-yxwxo4lacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs awk">[mongodb-org-<span class="hljs-number">3.4</span>]  <br>name=MongoDB Repository  <br>baseurl=https:<span class="hljs-regexp">//</span>repo.mongodb.org<span class="hljs-regexp">/yum/</span>redhat<span class="hljs-regexp">/$releasever/m</span>ongodb-org<span class="hljs-regexp">/3.4/</span>x86_64/  <br>gpgcheck=<span class="hljs-number">1</span>  <br>enabled=<span class="hljs-number">1</span>  <br>gpgkey=https:<span class="hljs-regexp">//</span>www.mongodb.org<span class="hljs-regexp">/static/</span>pgp/server-<span class="hljs-number">3.4</span>.asc<br><br></code></pre></td></tr></table></div></figure>

<ul>
<li>  这里可以修改 gpgcheck=0, 省去gpg验证</li>
<li>  <code>yum makecache</code> 就是把服务器的包信息下载到本地电脑缓存起来</li>
</ul>
<h4 id="4-2-2-更新缓存"><a href="#4-2-2-更新缓存" class="headerlink" title="4.2.2 更新缓存"></a>4.2.2 更新缓存</h4><figure class="highlight ebnf"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-y3dn0llacl5vph"></i><span>ebnf</span><div class="collapse show" id="collapse-y3dn0llacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs ebnf"><span class="hljs-attribute">yum makecache</span><br><br></code></pre></td></tr></table></div></figure>

<h4 id="4-2-3-安装"><a href="#4-2-3-安装" class="headerlink" title="4.2.3 安装"></a>4.2.3 安装</h4><figure class="highlight mipsasm"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-9am5z1lacl5vph"></i><span>mipsasm</span><div class="collapse show" id="collapse-9am5z1lacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs mipsasm">yum -y <span class="hljs-keyword">install </span>mongodb-<span class="hljs-keyword">org</span><br><span class="hljs-keyword"></span><br></code></pre></td></tr></table></div></figure>

<h4 id="4-2-4-修改配置文件"><a href="#4-2-4-修改配置文件" class="headerlink" title="4.2.4 修改配置文件"></a>4.2.4 修改配置文件</h4><figure class="highlight awk"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-0dd0gxlacl5vph"></i><span>awk</span><div class="collapse show" id="collapse-0dd0gxlacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs awk">whereis mongod<br>vi <span class="hljs-regexp">/etc/m</span>ongod.conf<br><br></code></pre></td></tr></table></div></figure>

<p>/etc/mongod.conf</p>
<figure class="highlight dts"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-hzl9tzlacl5vph"></i><span>dts</span><div class="collapse show" id="collapse-hzl9tzlacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs dts"><span class="hljs-symbol">net:</span><br><span class="hljs-symbol">  port:</span> <span class="hljs-number">27017</span><br><span class="hljs-meta">#  bindIp: 127.0.0.1 </span><br><br></code></pre></td></tr></table></div></figure>

<h4 id="4-2-5-启动服务"><a href="#4-2-5-启动服务" class="headerlink" title="4.2.5 启动服务"></a>4.2.5 启动服务</h4><figure class="highlight nsis"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-09ivu1lacl5vph"></i><span>nsis</span><div class="collapse show" id="collapse-09ivu1lacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs nsis"><span class="hljs-params">system</span>ctl start mongod.service<br><span class="hljs-params">system</span>ctl stop mongod.service<br><span class="hljs-params">system</span>ctl status mongod.service<br><span class="hljs-params">system</span>ctl restart mongod.service<br><br></code></pre></td></tr></table></div></figure>

<h4 id="4-2-6-远程连接"><a href="#4-2-6-远程连接" class="headerlink" title="4.2.6 远程连接"></a>4.2.6 远程连接</h4><figure class="highlight gauss"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-cug77elacl5vph"></i><span>gauss</span><div class="collapse show" id="collapse-cug77elacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs gauss">systemctl <span class="hljs-keyword">stop</span> firewalld.service <span class="hljs-meta">#停止firewall</span><br>systemctl <span class="hljs-keyword">disable</span> firewalld.service <span class="hljs-meta">#禁止firewall开机启动</span><br>mongo <span class="hljs-number">115.29</span><span class="hljs-number">.148</span><span class="hljs-number">.6</span><br><br></code></pre></td></tr></table></div></figure>

<h3 id="4-3-redis"><a href="#4-3-redis" class="headerlink" title="4.3 redis"></a>4.3 redis</h3><h4 id="4-3-1-安装软件"><a href="#4-3-1-安装软件" class="headerlink" title="4.3.1 安装软件"></a>4.3.1 安装软件</h4><figure class="highlight cmake"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-7t7z5klacl5vph"></i><span>cmake</span><div class="collapse show" id="collapse-7t7z5klacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs cmake">yum <span class="hljs-keyword">install</span> redis -y<br><br></code></pre></td></tr></table></div></figure>

<h4 id="4-3-2-启动服务"><a href="#4-3-2-启动服务" class="headerlink" title="4.3.2 启动服务"></a>4.3.2 启动服务</h4><figure class="highlight nsis"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-28av21lacl5vph"></i><span>nsis</span><div class="collapse show" id="collapse-28av21lacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs nsis"><span class="hljs-params">system</span>ctl start redis.service<br><span class="hljs-params">system</span>ctl stop redis.service<br><span class="hljs-params">system</span>ctl status redis.service<br><span class="hljs-params">system</span>ctl restart redis.service<br><br></code></pre></td></tr></table></div></figure>

<h3 id="4-4-mysql"><a href="#4-4-mysql" class="headerlink" title="4.4 mysql"></a>4.4 mysql</h3><h4 id="4-4-1-查看最新的安装包"><a href="#4-4-1-查看最新的安装包" class="headerlink" title="4.4.1 查看最新的安装包"></a>4.4.1 查看最新的安装包</h4><ul>
<li>  <a target="_blank" rel="noopener" href="https://dev.mysql.com/downloads/repo/yum/">https://dev.mysql.com/downloads/repo/yum/</a></li>
</ul>
<h4 id="4-4-2-下载MySQL源安装包"><a href="#4-4-2-下载MySQL源安装包" class="headerlink" title="4.4.2 下载MySQL源安装包"></a>4.4.2 下载MySQL源安装包</h4><ul>
<li>  wget <a target="_blank" rel="noopener" href="http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm">http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm</a></li>
</ul>
<h4 id="4-4-3-安装源"><a href="#4-4-3-安装源" class="headerlink" title="4.4.3 安装源"></a>4.4.3 安装源</h4><ul>
<li>  yum -y install mysql57-community-release-el7-11.noarch.rpm</li>
<li>  yum repolist enabled | grep mysql.*</li>
</ul>
<h4 id="4-4-4-安装MYSQL服务器"><a href="#4-4-4-安装MYSQL服务器" class="headerlink" title="4.4.4 安装MYSQL服务器"></a>4.4.4 安装MYSQL服务器</h4><ul>
<li>  <code>yum install mysql-community-server -y</code></li>
</ul>
<figure class="highlight awk"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-mx1kb6lacl5vph"></i><span>awk</span><div class="collapse show" id="collapse-mx1kb6lacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs awk"><span class="hljs-regexp">/var/</span>cache<span class="hljs-regexp">/yum/</span>x86_64<span class="hljs-regexp">/7/my</span>sql57-community/packages<br>https:<span class="hljs-regexp">//mi</span>rrors.ustc.edu.cn<span class="hljs-regexp">/mysql-ftp/</span>Downloads<span class="hljs-regexp">/MySQL-5.7/</span><br>wget https:<span class="hljs-regexp">//img</span>.zhufengpeixun.com/mysql5.<span class="hljs-number">7</span>-centos7.zip<br><br></code></pre></td></tr></table></div></figure>

<h4 id="4-4-5-启动服务器"><a href="#4-4-5-启动服务器" class="headerlink" title="4.4.5 启动服务器"></a>4.4.5 启动服务器</h4><figure class="highlight nsis"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-um8yh9lacl5vph"></i><span>nsis</span><div class="collapse show" id="collapse-um8yh9lacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs nsis"><span class="hljs-params">system</span>ctl start mysqld.service<br><span class="hljs-params">system</span>ctl stop mysqld.service<br><span class="hljs-params">system</span>ctl status mysqld.service<br><span class="hljs-params">system</span>ctl restart mysqld.service<br><br></code></pre></td></tr></table></div></figure>

<h4 id="4-4-6-初始化数据库密码"><a href="#4-4-6-初始化数据库密码" class="headerlink" title="4.4.6 初始化数据库密码"></a>4.4.6 初始化数据库密码</h4><ul>
<li>  grep “password” /var/log/mysqld.log</li>
<li>  mysql -uroot -p</li>
<li>  ALTER USER ‘root‘@’localhost’ IDENTIFIED BY ‘abcd1#EFG’;</li>
<li>  SHOW VARIABLES LIKE ‘validate_password%’;</li>
</ul>
<h4 id="4-4-7-支持远程访问"><a href="#4-4-7-支持远程访问" class="headerlink" title="4.4.7 支持远程访问"></a>4.4.7 支持远程访问</h4><ul>
<li>  GRANT ALL PRIVILEGES ON <em>.</em> TO ‘root‘@’%’ IDENTIFIED BY ‘abcd1#EFG’ WITH GRANT OPTION;</li>
<li>  FLUSH PRIVILEGES;</li>
</ul>
<h4 id="4-4-8-开机自动访问"><a href="#4-4-8-开机自动访问" class="headerlink" title="4.4.8 开机自动访问"></a>4.4.8 开机自动访问</h4><ul>
<li>  systemctl enable mysqld</li>
<li>  systemctl daemon-reload</li>
</ul>
<h4 id="4-4-9-远程访问"><a href="#4-4-9-远程访问" class="headerlink" title="4.4.9 远程访问"></a>4.4.9 远程访问</h4><ul>
<li>  C:\program1\mysql-5.7.31-winx64\bin\mysqld MySQL</li>
</ul>
<figure class="highlight apache"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-xmpefslacl5vph"></i><span>apache</span><div class="collapse show" id="collapse-xmpefslacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs apache"><span class="hljs-attribute">mysql</span> -h<span class="hljs-number">115.29.148.6</span> -uroot -p<br><br></code></pre></td></tr></table></div></figure>
                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/%E8%BF%90%E7%BB%B4/" class="category-chain-item">运维</a>
  
  
    <span>></span>
    
  <a href="/categories/%E8%BF%90%E7%BB%B4/linux/" class="category-chain-item">linux</a>
  
  

  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/%E8%BF%90%E7%BB%B4/">#运维</a>
      
        <a href="/tags/linux/">#linux</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>06.软件包管理</div>
      <div>http://81.68.132.127/2022/10/24/dev_ops/linux/软件包管理/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>Ikki</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2022年10月24日</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>更新于</div>
          <div>2022年10月24日</div>
        </div>
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2022/10/24/dev_ops/linux/%E8%BF%9B%E7%A8%8B%E7%AE%A1%E7%90%86/" title="07.进程管理">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">07.进程管理</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2022/10/23/dev_ops/linux/%E6%9D%83%E9%99%90/" title="04.权限">
                        <span class="hidden-mobile">04.权限</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
  <article id="comments" lazyload>
    
  <div id="valine"></div>
  <script type="text/javascript">
    Fluid.utils.loadComments('#valine', function() {
      Fluid.utils.createScript('https://lib.baomitu.com/valine/1.5.1/Valine.min.js', function() {
        var options = Object.assign(
          {"appId":"6KzYWc2oaEBaHgNl4UIicMJC-gzGzoHsz","appKey":"vJ4FIwKeHRmHraCJraAsjyZ7","path":"window.location.pathname","placeholder":"请输入你的评论\n昵称为必填项目(输入QQ号码可以自动获取昵称和邮箱)\n虽然email不是必选，但是填写了email可以收到推送通知哦！","avatar":"retro","meta":["nick","mail","link"],"requiredFields":[],"pageSize":10,"lang":"zh-CN","highlight":true,"recordIP":true,"serverURLs":"","emojiCDN":null,"emojiMaps":null,"enableQQ":true},
          {
            el: "#valine",
            path: window.location.pathname
          }
        )
        new Valine(options);
        Fluid.utils.waitElementVisible('#valine .vcontent', () => {
          var imgSelector = '#valine .vcontent img:not(.vemoji)';
          Fluid.plugins.imageCaption(imgSelector);
          Fluid.plugins.fancyBox(imgSelector);
        })
      });
    });
  </script>
  <noscript>Please enable JavaScript to view the comments</noscript>


  </article>


          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
      IKKI-专业BUG开发
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="busuanzi_container_site_pv" style="display: none">
        总访问量 
        <span id="busuanzi_value_site_pv"></span>
         次
      </span>
    
    
      <span id="busuanzi_container_site_uv" style="display: none">
        总访客数 
        <span id="busuanzi_value_site_uv"></span>
         人
      </span>
    
    
  
</div>

  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>




  
<script src="/fluid/js/star.js"></script>



<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
